<?php
namespace app\admin\controller;

use app\admin\logic\MemberLogic;
use app\BaseController;
use think\facade\Request;
use think\facade\View;
//会员列表
class Member extends BaseController
{
    //添加会员
    public function memberAdd()
    {
        if (Request::isPost()){
            //接值
            $post = Request::post();
            //逻辑层处理添加数据
            $add = MemberLogic::addMemberInfo($post);
            //模型层添加数据
            $res = \app\admin\model\Member::addMemberAttr($add);
            if ($res){
                $this->success('添加成功',url('memberList'));
            }else{
                $this->error('添加失败');
            }
        }
        return View::fetch();
    }
    //会员列表
    public function memberList()
    {

        //接值
        $get = Request::get();
        //逻辑层处理搜索数据
        $where = MemberLogic::getWhereInfo($get);
        //留值
        $data = MemberLogic::getData($get);
        View::assign($data);
        //会员列表展示
        $list = \app\admin\model\Member::getMemberInfo($where,$data);
        //分页
        $page = $list->render();
        View::assign(['list'=>$list,'page'=>$page]);
        return View::fetch();
    }
    //单个软删除会员
    public function memberDel()
    {
        //接值
        $get = Request::get();
        //模型层执行删除语句
        $res = \app\admin\model\Member::memberDel($get);
        //判断是否删除成功
        if ($res){
            $this->success('删除成功',url('memberList'));
        }else{
            $this->error('删除失败');
        }
    }
    //多个软删除会员
    public function memberDels()
    {
        //接值
        $get = Request::get();
        //模型层执行删除语句
        $res = \app\admin\model\Member::memberDels($get);
        //判断是否删除成功
        if ($res){
            $this->success('删除成功',url('memberList'));
        }else{
            $this->error('删除失败');
        }
    }

}